﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using IHISCETeim.BLL;
using IHISCETeim.Library;
using IHISCETeim.Model;

namespace IHISCETeim.Web.MachineSys.JSDWF
{
    public partial class JSDWF_ApplyDWFView : PageBase
    {
        protected override Permission[] PowerKey
        {
            get
            {
                return new Permission[] { Permission.none };
            }
        }
        protected override string DWZRef
        {
            get { return "JSDWFList"; }
        }

        /// <summary>
        /// 需审批的申请
        /// </summary>
        protected Guid ApplyGUID
        {
            get
            {
                string g = GetRequestValue<string>("g", "");
                if (g == "")
                    throw new Exception("服务器不接受您的请求.");
                return new Guid(g);
            }
        }
        
        protected string Remark
        {
            get
            {
                return "";
            }
        }

        private JSDWFApplyInfo _applyObj = null;
        protected JSDWFApplyInfo applyObj
        {
            get
            {
                if (_applyObj == null)
                    _applyObj = JSDWFApplyController.GetByApplyGUID(ApplyGUID);
                return _applyObj;
            }
        }

        private OUserInfo _ApplyUser = null;
        protected OUserInfo ApplyUser
        {
            get
            {
                if (_ApplyUser == null)
                    _ApplyUser = OUserController.GetByUserName(applyObj.ApplyUserName);
                return _ApplyUser;
            }
        }


        private OUserInfo _CurrFlowUser = null;
        protected OUserInfo CurrFlowUser
        {
            get
            {
                if (_CurrFlowUser == null)
                {
                    // OUserInfo ApplyUser = OUserController.GetByUserName(itm.ApplyUserName);//申请人员
                    JSDWFFlowConfigInfo flowObj = JSDWFFlowConfigController.GetByFlowId(applyObj.FlowID,applyObj.AdtlvlID);
                    _CurrFlowUser = OUserController.GetByUserName(flowObj.UserName);//审批人员
                }
                return _CurrFlowUser;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            //this.ltmsg.Text = proccess();
            if (base.User.UserName != CurrFlowUser.UserName)
            {
                Response.Write("提示:此申请无需你进行审批.");
                Response.End();
            }

            if (applyObj.ApplyState != 0)
            {
                Response.Write( "提示:此申请您已审批过,无需再进行审批.");
                Response.End();
            }

            DataTable detaildt = JSDWFApplyController.GetDetailByApplyGUID(ApplyGUID);
            this.rpMenu.DataSource = detaildt;
            this.rpMenu.DataBind();

            lsttitle.Text = string.Format("<b>{0}</b> 正在申请使用以下图纸,请审核.",ApplyUser.RealName);
        }

       
    }
}